package com.wzy.controller;

import com.wzy.annotation.SystemLog;
import com.wzy.domain.ResponseResult;
import com.wzy.domain.vo.CategoryListVO;
import com.wzy.service.CategoryService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 分类管理控制器
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/category")
public class CategoryController
{
    private final CategoryService categoryService;

    /**
     * 查询分类列表
     */
    @GetMapping("/getCategoryList")
    @SystemLog(basenessName = "查询分类列表")
    public ResponseResult<List<CategoryListVO>> categoryList()
    {
        return categoryService.getCategoryList();
    }

    /**
     * 新建文章分类
     */
    @PostMapping("/addCategory")
    @SystemLog(basenessName = "新建文章分类")
    public ResponseResult<Void> addCategory(@Validated @RequestBody CategoryListVO category)
    {
        return categoryService.addCategory(category);
    }

}
